﻿using System;
using Jet.Utilities.Serialization;
using NUnit.Framework;

namespace Jet.Utilities.Tests
{
	[TestFixture]
	public class SerializationServiceTests
	{
		[Test]
		public void TestAll()
		{
			var serializer = new SerializationService();
			var testString = Guid.NewGuid().ToString();
			var buffer = serializer.SerializeObject(testString);
			var result = serializer.DeserializeObject<string>(buffer);
			Assert.That(result, Is.EqualTo(testString));

			Assert.That(() => serializer.SerializeObject(null), Throws.TypeOf<ArgumentNullException>());
			Assert.That(() => serializer.SerializeObject("Some string", -1), Throws.TypeOf<ArgumentOutOfRangeException>());
			Assert.That(() => serializer.DeserializeObject<int>(null), Throws.TypeOf<ArgumentNullException>());
		}
	}
}
